package cn.edu.lingnan.fruitshop.exception;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class GlabalException {
    @ExceptionHandler(Exception.class)
    public String globalException(Exception e, Model model, HttpServletRequest request){
        model.addAttribute("exception",e);
        model.addAttribute("url",request.getRequestURL());
        return "error";
    }
}
